import { Button,Form,message } from "antd";
import { FormItemButton, FormItemInput, FormItemSelect, FormItemUpload } from "@/components/antd/form/index";
import { StaffRole } from "@/definition/enum/StaffEnum";
import { API } from "@/request/api";
import { useNavigate } from "react-router-dom";
const StaffDetails =() =>{
    const navigate = useNavigate();
    const [form] = Form.useForm();
    const onUoload = () =>{

    }
    const onConfirm = async () =>{
        try{
           await API.createStaffItem(form.getFieldsValue());
           message.success("创建成功");
           navigate('/staff/items');
        }catch{

        }
    }
    const onReset = () =>{
        form.resetFields();
    }
    return (
        <>
        <Form form={form}>
            <FormItemInput name="username" label="账号" require/>
            <FormItemInput name="nickname" label="昵称" require/>
            <FormItemUpload name="avatar" filelist={[]} label="头像" onUpload={onUoload}/>
            <FormItemSelect name="role" label="角色" require options={StaffRole}/>
            <FormItemButton onConfirm={onConfirm} onReset={onReset} offset={1}/>
        </Form>
        </>
    )
}
export default StaffDetails;